package com.workflow.workflowproject.until;

import lombok.Getter;

@Getter
public enum FieldEnum {
    HIDDEN("hidden","hidden","NO",0,0,0),
    INPUT("input","input","ElInput",0,0,0),
    INPUT_NUMBER("inputNumber","stepper","ElInputNumber",0,0,0),
    CALENDAR("datePicker","calendar","ElCalendar",0,0,0),
    RADIO("radio","radio","ElRadio",1,0,0),
    CHECK_BOX("checkbox","checkbox","ElCheckbox",1,0,0),
    SELECT("select","select","ElSelect",1,0,0),
    SWITCH("switch","switch","ElSwitch",0,0,0),
    CASCADER("cascader","cascader","ElCarousel",1,0,0),
    DATE_PICKER("datePicker","datePicker","ElDatePicker",0,0,0),
    TIME_PICKER("timePicker","timePicker","ElTimePicker",0,0,0),
    RATE("rate","rate","ElRate",0,0,0),
    SLIDER("slider","slider","ElSlider",0,0,0),
    UPLOAD("upload","uploader","ElUpload",0,0,1);


    private final String elementType;//element ui的类型
    private final String vantType;//vant 的类型
    private final String lowFormType;//lowFlow 的类型
    private final Integer optionType;//是否有Options 的类型
    private final Integer isCustomComponents;//是否自定义组件（0、否;1、是）
    private final Integer isFile;//是否存在附件（用于展示附件）（0、否;1、是）

    FieldEnum(String elementType,String vantType,String lowFormType,Integer optionType,Integer isCustomComponents,Integer isFile){
        this.elementType = elementType;
        this.vantType = vantType;
        this.lowFormType = lowFormType;
        this.optionType = optionType;
        this.isCustomComponents = isCustomComponents;
        this.isFile = isFile;
    }

    //将Element Ui 组件转 vant 组件
    public static Integer getOptionByElementType(String type) {
        for(FieldEnum fieldEnum : FieldEnum.values()){
            if(fieldEnum.elementType.equals(type)){
                return fieldEnum.optionType;
            }
        }
        return 0;
    }
    //将 vant 组件转 Element Ui 组件
    public static Integer getOptionByVantType(String type) {
        for(FieldEnum fieldEnum : FieldEnum.values()){
            if(fieldEnum.vantType.equals(type)){
                return fieldEnum.optionType;
            }
        }
        return 0;
    }
    //将 Element Ui 组件转 vant 的type组件
    public static String getVantTypeByElementType(String type) {
        String typeName = "";
        for(FieldEnum fieldEnum : FieldEnum.values()){
            if(fieldEnum.elementType.equals(type)){
                typeName = fieldEnum.vantType;
            }
        }
        return typeName;
    }

    //判断是否参与条件组成
    public static String isLowFormType(String type) {
        String isInType = "NO";
        for(FieldEnum fieldEnum : FieldEnum.values()){
            if(fieldEnum.elementType.equals(type)){
                if(!fieldEnum.lowFormType.equals("NO")){
                    isInType = fieldEnum.lowFormType;
                }
            }
        }
        return isInType;
    }

    //判断是否是自定义组件
    public static String getIsCustomComponentsType(String type) {
        String isInType = "NO";
        for(FieldEnum fieldEnum : FieldEnum.values()){
            if(fieldEnum.elementType.equals(type)){
                if(fieldEnum.getIsCustomComponents().compareTo(1) == 0){
                    return "YES";
                }
            }
        }
        return isInType;
    }

    //判断是否是右附件
    public static String getIsFileType(String type) {
        String isInType = "NO";
        for(FieldEnum fieldEnum : FieldEnum.values()){
            if(fieldEnum.elementType.equals(type)){
                if(fieldEnum.getIsFile().compareTo(1) == 0){
                    return "YES";
                }
            }
        }
        return isInType;
    }
}
